package com.ard.camera.demos.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "host.monitor")
@Data
public class HostMonitorConfig {
    private String hostDir = "hosts";           // 主机文件目录
    private String fileSuffix = ".txt";
    private long interval = 60000; // 默认1分钟
    private int timeout = 5000;    // 默认5秒超时
    private int retryCount = 3;    // 默认重试3次
    private EmailConfig email = new EmailConfig();

    @Data
    public static class EmailConfig {
        private String from;
        private String to; // 多个收件人用逗号分隔
        private String subject = "主机监控告警";

        /**
         * 获取收件人列表
         */
        public String[] getToAddresses() {
            if (to == null || to.trim().isEmpty()) {
                return new String[0];
            }
            return to.split("\\s*,\\s*");
        }
    }
}